<?php
	error_reporting(E_ALL ^E_NOTICE);
	
	session_start();	
	if ((!isset($_SESSION['username'])) && (!isset($_SESSION['password']))) {
		header("location:index.php"); //not logged in, redirect to login page
	}
	$con = mysql_connect("localhost","root","") or die("Can't connect to database. Contact Your Administrator.");	
	mysql_select_db("gestation") or die("Cannot select DB. Contact your web administrator.");
	
	require_once('head.php');
?>
<script>
	$(document).ready(function() {
		$("#menu_1").css("color","#035C8C");
		$("#menu_2").css("color","#B6DD53");
		$("#menu_3").css("color","#035C8C");
	});	
</script>
<div id="container">
	<br><br>
	<div style="width:20%; margin-left:auto; margin-right:auto; color:red; font-size:17px;">
	<?php
		if (isset($_POST['submitData'])) {
			$motherName = $_POST['input_mother_name'];
			$motherAddr = $_POST['input_mother_address'];			
			$motherWeight = $_POST['input_mother_weight'];
			$motherHeight = $_POST['input_mother_height'];
			$motherEtnis = $_POST['input_mother_etnis'];
			$motherPar = $_POST['input_mother_parity'];
			$embrioEDD = $_POST['input_mother_edd'];
			$embrioSex =  $_POST['input_kelamin'];
			
			$sql = "INSERT INTO mother(mother_name, mother_address, mother_etnis, mother_parity, mother_weight, mother_height) 
			VALUES('$motherName', '$motherAddr', '$motherEtnis', '$motherPar', '$motherWeight', '$motherHeight')";
			mysql_query($sql, $con) or die("Error Input Pasien Baru 1. Contact your administrator");
			$id = mysql_insert_id();
			
			$sql1 = "INSERT INTO embrio(embrio_mother_id, embrio_edd, embrio_sex) VALUES ('$id', '$embrioEDD', '$embrioSex')"; 
			mysql_query($sql1, $con) or die("Error Input Pasien Baru 2. Contact your administrator");
			
			echo "Data berhasil disimpan";
		}
	?>
	</div> <br>
	<form id="add_mother_form" name="add_mother_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
		<table border="0" id="add_mother_table">
			<tr>
				<td width="30%;"> Nama </td>
				<td width="70%;"> <input type="text" name="input_mother_name" id="input_mother_name" style="width:100%;" value=""/> </td>
			</tr>
			<tr>
				<td> Alamat </td>
				<td> <textarea name="input_mother_address" id="input_mother_address" rows="4" style="width:100%;"></textarea> </td>
			</tr>
			<tr>
				<td> EDD</td>
				<td> <input type="date" name="input_mother_edd" id="input_mother_edd" value=""/> </td>
			</tr>
			<tr>
				<td> Etnis </td>
				<td> 
					<select name="input_mother_etnis" id="input_mother_etnis">
						<option id="etnis_0" value="0"> Indian </option>	<!-- -206.4 -->
						<option id="etnis_1" value="1"> Pakistani </option> <!-- -156.8 -->
						<option id="etnis_2" value="2"> Bangladeshi </option> <!-- -125.7 -->
						<option id="etnis_3" value="3"> African Caribbean </option> <!-- -116 -->
						<option id="etnis_4" value="4"> African (sub Sahara) </option> <!-- -63.7 -->
						<option id="etnis_5" value="5"> Middle East (inc North Africa) </option> <!-- -90 -->
						<option id="etnis_6" value="6"> Far East Asian (eg China, Japan) </option> <!-- 64 -->
						<option id="etnis_7" value="7"> South East Asia (eg Thailand, Indonesia, Philippines) </option> <!-- 71.5 -->
						<option id="etnis_8" value="8"> Other </option> <!-- -60 -->
					</select>
				</td>
			
			</tr>
			<tr>
				<td> Tinggi </td>
				<td> <input type="text" name="input_mother_height" id="input_mother_height" value=""/> cm </td>
			</tr>
			<tr>
				<td> Berat </td>
				<td> <input type="text" name="input_mother_weight" id="input_mother_weight" value=""/> kg </td>
			</tr>
			<tr>
				<td> Parity </td>
				<td> 
					<select name="input_mother_parity" id="input_mother_parity">
						<option id="parity_0" value="0">	0  </option> <!-- value = 0 -->
						<option id="parity_1" value="1">	1  </option> <!-- value = +111.0 -->
						<option id="parity_2" value="2">	2  </option> <!-- value = +154.8 -->
						<option id="parity_3" value="3">	3+ </option> <!-- value = +151.3 -->
					</select>
				</td>
			</tr>
			<tr>
				<td> Jenis Kelamin Janin </td>
				<td align="left">
					<label for="select"></label>
					<select name="input_kelamin" id="input_kelamin">
						<option id="sex_unknown" value="-1"> Belum diketahui</option>
						<option id="sex_male" value="1"> Laki</option> <!-- value = +52.6 -->
						<option id="sex_female" value="0">Perempuan</option> <!-- value = -52.6 -->
					</select>
				</td>
			</tr>
			<tr>
				<td></td>
				<td> <br> <input type="submit" name="submitData" id="submitData" value="Submit" style="width:90px; height:30px;"/> </td>
			</tr>	
		</table>
	</form>		
</div>		
	<div>
	<?php
		require_once('footer.php');			
		mysql_close();	
	?>